import java.util.Arrays;

public class FindContentChildren {
    // https://leetcode.cn/problems/assign-cookies
    class Solution {
        public int findContentChildren(int[] g, int[] s) {

            Arrays.sort(g);
            Arrays.sort(s);
            int cnt = 0;
            for(int i = 0 ,j = 0 ; i < g.length && j < s.length ;)
            {
                if(g[i] <= s[j])
                {
                    cnt++;
                    i ++;
                    j ++;
                }else
                {
                    j ++;
                }
            }
            return cnt;
        }
    }
}
